;2008-05-20
;Av Benjamin Ingberg och Patrik Johansson
;
;Samarbetar med world object för att rita ut dödsanimationerna
;som ligger i animations


(load "world-object.scm")

(define animation%
  (class world-object%
    (init sprites
          x
          y
          w
          h
          board)
    (super-new [x x][y y][w w][h h][sprites sprites])
    
    (define/override (collides? x y w h)
      #f)
    
    (define _board board)
    (define _counter 0)
    (define _sprite #f)
    
    (define/override (draw)
      (if (> _counter 0)
          (begin (draw-sprite-square _sprite
                                     (send this get-x)
                                     (send this get-y)
                                     (send this get-w)
                                     (send this get-h))
                 (set! _counter (- _counter 1)))
          (let ((sprites (send this get-sprites)))
            (if (null? sprites)
                (send _board kill this)
                (let ((sprite (car sprites)))
                  (send this set-sprites (cdr sprites))
                  (set! _counter (car sprite))
                  (set! _sprite (cdr sprite))
                  (send this draw))))))))